
#include "nx_api.h"

#ifdef __PRODUCT_NETXDUO__

#include "netx_mdns_test.h"

/* Frame (75 bytes) */
static const unsigned char pkt1[75] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0xec, 0x17, /* ..^..... */
0x2f, 0xbd, 0xa4, 0xb1, 0x08, 0x00, 0x45, 0x00, /* /.....E. */
0x00, 0x3d, 0x01, 0x81, 0x00, 0x00, 0xff, 0x11, /* .=...... */
0x11, 0x81, 0xc0, 0xa8, 0x07, 0x0a, 0xe0, 0x00, /* ........ */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x29, /* .......) */
0xa9, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* .&...... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, /* ......._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x0c, 0x00, 0x01                                /* ... */
};

/* Frame (373 bytes) */
static const unsigned char pkt2[373] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x00, 0x11, /* ..^..... */
0x22, 0x33, 0x44, 0x57, 0x08, 0x00, 0x45, 0x00, /* "3DW..E. */
0x01, 0x67, 0x00, 0x08, 0x40, 0x00, 0xff, 0x11, /* .g..@... */
0x8f, 0x40, 0x0a, 0x00, 0x00, 0x42, 0xe0, 0x00, /* .@...B.. */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x01, 0x53, /* .......S */
0xf4, 0x39, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, /* .9...... */
0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x04, 0x5f, /* ......._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, /* ......d. */
0x1d, 0x0b, 0x41, 0x52, 0x4d, 0x4d, 0x44, 0x4e, /* ..ARMMDN */
0x53, 0x54, 0x65, 0x73, 0x74, 0x04, 0x5f, 0x69, /* STest._i */
0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, 0x05, /* pp._tcp. */
0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x0b, 0x41, /* local..A */
0x52, 0x4d, 0x4d, 0x44, 0x4e, 0x53, 0x54, 0x65, /* RMMDNSTe */
0x73, 0x74, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, /* st.local */
0x00, 0x00, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, /* ........ */
0x78, 0x00, 0x04, 0x0a, 0x00, 0x00, 0x42, 0x0b, /* x.....B. */
0x41, 0x52, 0x4d, 0x4d, 0x44, 0x4e, 0x53, 0x54, /* ARMMDNST */
0x65, 0x73, 0x74, 0x05, 0x6c, 0x6f, 0x63, 0x61, /* est.loca */
0x6c, 0x00, 0x00, 0x2f, 0x80, 0x01, 0x00, 0x00, /* l../.... */
0x00, 0x78, 0x00, 0x16, 0x0b, 0x41, 0x52, 0x4d, /* .x...ARM */
0x4d, 0x44, 0x4e, 0x53, 0x54, 0x65, 0x73, 0x74, /* MDNSTest */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x01, 0x40, 0x0b, 0x41, 0x52, 0x4d, 0x4d, 0x44, /* .@.ARMMD */
0x4e, 0x53, 0x54, 0x65, 0x73, 0x74, 0x04, 0x5f, /* NSTest._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x21, 0x80, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, /* !.....d. */
0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x0b, /* ......P. */
0x41, 0x52, 0x4d, 0x4d, 0x44, 0x4e, 0x53, 0x54, /* ARMMDNST */
0x65, 0x73, 0x74, 0x05, 0x6c, 0x6f, 0x63, 0x61, /* est.loca */
0x6c, 0x00, 0x0b, 0x41, 0x52, 0x4d, 0x4d, 0x44, /* l..ARMMD */
0x4e, 0x53, 0x54, 0x65, 0x73, 0x74, 0x04, 0x5f, /* NSTest._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x10, 0x80, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, /* ......d. */
0x01, 0x00, 0x0b, 0x41, 0x52, 0x4d, 0x4d, 0x44, /* ...ARMMD */
0x4e, 0x53, 0x54, 0x65, 0x73, 0x74, 0x04, 0x5f, /* NSTest._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x2f, 0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, /* /.....x. */
0x24, 0x0b, 0x41, 0x52, 0x4d, 0x4d, 0x44, 0x4e, /* $.ARMMDN */
0x53, 0x54, 0x65, 0x73, 0x74, 0x04, 0x5f, 0x69, /* STest._i */
0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, 0x05, /* pp._tcp. */
0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, 0x05, /* local... */
0x00, 0x00, 0x80, 0x00, 0x40                    /* ....@ */
};

/* Frame (101 bytes) */
static const unsigned char pkt3[101] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0xec, 0x17, /* ..^..... */
0x2f, 0xbd, 0xa4, 0xb1, 0x08, 0x00, 0x45, 0x00, /* /.....E. */
0x00, 0x57, 0x01, 0x82, 0x00, 0x00, 0xff, 0x11, /* .W...... */
0x11, 0x66, 0xc0, 0xa8, 0x07, 0x0a, 0xe0, 0x00, /* .f...... */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x43, /* .......C */
0x10, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, /* ......._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x0c, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x0c, 0x00, /* ........ */
0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x0e, 0x0b, /* ....d... */
0x41, 0x52, 0x4d, 0x4d, 0x44, 0x4e, 0x53, 0x54, /* ARMMDNST */
0x65, 0x73, 0x74, 0xc0, 0x0c                    /* est.. */
};

/* Frame (101 bytes) */
static const unsigned char pkt4[101] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0xec, 0x17, /* ..^..... */
0x2f, 0xbd, 0xa4, 0xb1, 0x08, 0x00, 0x45, 0x00, /* /.....E. */
0x00, 0x57, 0x01, 0x82, 0x00, 0x00, 0xff, 0x11, /* .W...... */
0x11, 0x66, 0xc0, 0xa8, 0x07, 0x0a, 0xe0, 0x00, /* .f...... */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x43, /* .......C */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, /* ......._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x0c, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x0c, 0x00, /* ........ */
0x01, 0x00, 0x00, 0x00, 0x31, 0x00, 0x0e, 0x0b, /* ....d... */
0x41, 0x52, 0x4d, 0x4d, 0x44, 0x4e, 0x53, 0x54, /* ARMMDNST */
0x65, 0x73, 0x74, 0xc0, 0x0c                    /* est.. */
};

static MDNS_SERVICE mdns_service = {"ARMMDNSTest", "_ipp._tcp", NX_NULL, NX_NULL, 100, 0, 0, 80, NX_MDNS_RR_SET_UNIQUE, 0};

MDNS_TEST_SEQ mdns_known_answer_suppression_response[] = {
    {TITLE, "Known answer suppression response", 33, 0},
    {MDNS_SERVICE_ADD, (char*)&mdns_service, 0, 0},
    {WAIT, NX_NULL, 0, 5},
    {DUMP, NX_NULL, 0, 0},

    /* Queries with known answer. */
    {INJECT, (char*)&pkt3[0], sizeof(pkt3), 0},
    {INJECT, (char*)&pkt3[0], sizeof(pkt3), 0},
    {INJECT, (char*)&pkt3[0], sizeof(pkt3), 0},

    /* No responses are expected. */
    {MDNS_REJECT_DATA_V4, (char*)&pkt2[0], sizeof(pkt2), 1},

    /* Query only. */
    {INJECT, (char*)&pkt1[0], sizeof(pkt1), 0},

    /* Check response. */
    {MDNS_CHECK_DATA_V4, (char*)&pkt2[0], sizeof(pkt2), 2},
    
    /* Queries with known answer. */
    {INJECT, (char*)&pkt3[0], sizeof(pkt3), 0},

    /* No responses are expected. */
    {MDNS_REJECT_DATA_V4, (char*)&pkt2[0], sizeof(pkt2), 1},

    /* Queries with known answer. The TTL is less than half of the local RR. */
    {INJECT, (char*)&pkt4[0], sizeof(pkt4), 0},

    /* Expect a response. */
    {MDNS_CHECK_DATA_V4, (char*)&pkt2[0], sizeof(pkt2), 2},
};

int mdns_known_answer_suppression_response_size = sizeof(mdns_known_answer_suppression_response) / sizeof(MDNS_TEST_SEQ);

#endif /* __PRODUCT_NETXDUO__  */

